package org.darkforest.merchant.controller;

import org.darkforest.common.services.MemberPrivilegeService;
import org.darkforest.dao.mapper.MemberPrivilegeMapper;
import org.darkforest.model.MemberPrivilege;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

/**
 * Created by pc on 2017/4/10.
 */
@Controller
@RequestMapping(value="privilege")
public class MemberPrivilegeController {
    @Autowired
    private MemberPrivilegeMapper memberPrivilegeMapper;
    @Autowired
    private MemberPrivilegeService memberPrivilegeService;
    @RequestMapping(value = "list")
    public ModelAndView list(MemberPrivilege memberPrivilege){
        ModelAndView view = new ModelAndView("privilege/list");
        memberPrivilege = memberPrivilegeService.selectByCondition(memberPrivilege);
        view.addObject("page",memberPrivilege);
        return view;
    }
    @RequestMapping(value = "toedit")
     public ModelAndView toEdit(Integer id){
        ModelAndView view = new ModelAndView("privilege/edit");
        MemberPrivilege memberPrivilege = memberPrivilegeMapper.selectByPrimaryKey(id);
        view.addObject("memberPrivilege",memberPrivilege);
        return view;
    }
    @RequestMapping(value = "doedit")
    public String doEdit(MemberPrivilege memberPrivilege){
        memberPrivilegeMapper.updateByPrimaryKeySelective(memberPrivilege);
        return "redirect:list";
    }
}
